home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / enemy / SpaceManA.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  28.0 KB  |  902 lines

  1. class classes.enemy.SpaceManA
  2. {
  3.    var x;
  4.    var y;
  5.    var moveScript;
  6.    var matrixCoords;
  7.    var form;
  8.    var id;
  9.    var clip;
  10.    var colorR;
  11.    var trans;
  12.    var colorTrans;
  13.    var advanceMax;
  14.    var advanceMax2;
  15.    var matrixVar;
  16.    var laser;
  17.    var dir;
  18.    var axis;
  19.    var xDest;
  20.    var yDest;
  21.    var oldDir;
  22.    var cMax;
  23.    var xMov = 0;
  24.    var yMov = 0;
  25.    var xMovT = 0;
  26.    var yMovT = 0;
  27.    var speedOrig = 8;
  28.    var speed = 8;
  29.    var f2 = "";
  30.    var xDestMet = false;
  31.    var yDestMet = false;
  32.    var c = 0;
  33.    var c2 = 0;
  34.    var moveScripted = true;
  35.    var feelerInfo = [[-400,0,400,40],[0,0,400,40],[0,-400,40,400],[0,0,40,400]];
  36.    var dirArray = ["L","R","U","D"];
  37.    var life = 300;
  38.    var nudging = false;
  39.    var nc = 0;
  40.    var xA = 0;
  41.    var yA = 0;
  42.    var power = 30;
  43.    var hc = 0;
  44.    var Name = "spaceManA";
  45.    function SpaceManA(px, py, pmoveScript, pmatrixCoords, pform, pid)
  46.    {
  47.       this.x = px;
  48.       this.y = py;
  49.       this.moveScript = pmoveScript.slice();
  50.       this.matrixCoords = pmatrixCoords.slice();
  51.       this.form = pform.slice();
  52.       this.id = pid;
  53.       _root.d = _root.d + 1;
  54.       this.clip = _root.attachMovie("spaceManA","spaceManA" + this.id + "Clip",_root.d + 50000);
  55.       this.clip._x = this.x;
  56.       this.clip._y = this.y;
  57.       this.speed *= _root.dif.speed;
  58.       this.speedOrig = this.speed;
  59.       this.life *= _root.dif.life;
  60.       this.colorR = _root.randRange(-40,10);
  61.       this.trans = new flash.geom.Transform(this.clip.body);
  62.       this.colorTrans = new flash.geom.ColorTransform(1,1,1,1,this.colorR,this.colorR,this.colorR,0);
  63.       this.trans.colorTransform = this.colorTrans;
  64.       this.advanceMax = 60 / (this.speed / 2);
  65.       this.advanceMax2 = 50 / (this.speed / 2);
  66.       if(this.matrixCoords[0] == "free")
  67.       {
  68.          this.matrixVar = 0;
  69.       }
  70.       else
  71.       {
  72.          this.matrixVar = 1;
  73.       }
  74.       this.speedVar();
  75.       this.laser = new Object();
  76.       this.parseMoveScript();
  77.       _root.stats.created = _root.stats.created + 1;
  78.    }
  79.    function broBehind()
  80.    {
  81.       this.dir = _root.advanceDir;
  82.    }
  83.    function bombed(num)
  84.    {
  85.       num;
  86.       this.life -= num;
  87.       if(this.life < 1)
  88.       {
  89.          this.f2 = "death";
  90.       }
  91.       else
  92.       {
  93.          this.nudge(_root.randRange(-6,6),_root.randRange(-6,6),100);
  94.       }
  95.    }
  96.    function nudge(pxA, pyA, pscale)
  97.    {
  98.       this.nc = 0;
  99.       this.nudging = true;
  100.       var _loc2_ = pscale / 100;
  101.       this.xA = pxA * _loc2_;
  102.       this.yA = pyA * _loc2_;
  103.    }
  104.    function speedVar()
  105.    {
  106.       if(random(3) == 1)
  107.       {
  108.          this.speed *= _root.randRange2(0.9999,1.0001);
  109.       }
  110.    }
  111.    function parseMoveScript()
  112.    {
  113.       this.dir = this.moveScript[0];
  114.       if(this.dir == "break")
  115.       {
  116.          this.moveScripted = false;
  117.          delete this.moveScript;
  118.          if(this.matrixCoords[0] == "free")
  119.          {
  120.             this.f2 = "wander";
  121.             this[this.axis + "MovT"] = 0;
  122.             this.axis = random(10) <= 4 ? "y" : "x";
  123.             this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
  124.             this.speedVar();
  125.             this.getDirString();
  126.          }
  127.          else
  128.          {
  129.             this[this.axis + "MovT"] = 0;
  130.             this.xDest = _root.advanceDir != "L" ? this.matrixCoords[0] * 60 : this.matrixCoords[0] * 60 + 320;
  131.             this.yDest = this.matrixCoords[1] * 50 + 10;
  132.             this.axis = Math.abs(this.xDest - this.x) <= Math.abs(this.yDest - this.y) ? "y" : "x";
  133.             this[this.axis + "MovT"] = this[this.axis + "Dest"] <= this[this.axis] ? -1 * this.speed : this.speed;
  134.             this.getDirString();
  135.             this.speedVar();
  136.             this.f2 = "gotoMatrix";
  137.          }
  138.       }
  139.       else
  140.       {
  141.          this[this.axis + "MovT"] = 0;
  142.          this.f2 = "gotoXYDest";
  143.          this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  144.          this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  145.          this.speedVar();
  146.          if(this.dir == "L" || this.dir == "U")
  147.          {
  148.             this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
  149.          }
  150.          else
  151.          {
  152.             this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
  153.          }
  154.          this.moveScript.splice(0,2);
  155.       }
  156.    }
  157.    function gotoXYDest()
  158.    {
  159.       if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
  160.       {
  161.          if(this.axis == "x")
  162.          {
  163.             this.x = this.xDest;
  164.          }
  165.          else
  166.          {
  167.             this.y = this.yDest;
  168.          }
  169.          this.parseMoveScript();
  170.       }
  171.    }
  172.    function gotoMatrix()
  173.    {
  174.       if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
  175.       {
  176.          if(this.axis == "x")
  177.          {
  178.             this.x = this.xDest;
  179.          }
  180.          else
  181.          {
  182.             this.y = this.yDest;
  183.          }
  184.          this[this.axis + "MovT"] = 0;
  185.          this.axis = this.axis != "x" ? "x" : "y";
  186.          this[this.axis + "MovT"] = this[this.axis + "Dest"] <= this[this.axis] ? -1 * this.speed : this.speed;
  187.          this.getDirString();
  188.          this.speed = this.speedOrig;
  189.       }
  190.       if(Math.abs(this.x - this.xDest) < this.speed + 1 && Math.abs(this.y - this.yDest) < this.speed + 1)
  191.       {
  192.          this.x = this.clip._x = this.xDest;
  193.          this.y = this.clip._y = this.yDest;
  194.          this.xMovT = this.xMov = 0;
  195.          this.yMovT = this.yMov = 0;
  196.          this.matrixVar = 2;
  197.          this.dir = _root.advanceDir;
  198.          this.clip.body.gotoAndPlay("flyEnd");
  199.          this.clip.flame.gotoAndStop("wait");
  200.          this.clip.gotoAndStop(this.dir);
  201.          this.oldDir = "matrix";
  202.          _root.matrixNum = _root.matrixNum + 1;
  203.          if(_root.matrixNum >= _root.matrixSize)
  204.          {
  205.             _root.matrixComplete = true;
  206.          }
  207.          _root["formB" + this.form[0]] = "matrixed";
  208.          this.f2 = "wait";
  209.       }
  210.    }
  211.    function getDirString()
  212.    {
  213.       if(this.xMovT < -1)
  214.       {
  215.          this.dir = "L";
  216.       }
  217.       else if(this.xMovT > 1)
  218.       {
  219.          this.dir = "R";
  220.       }
  221.       else if(this.yMovT > 1)
  222.       {
  223.          this.dir = "D";
  224.       }
  225.       else if(this.yMovT < -1)
  226.       {
  227.          this.dir = "U";
  228.       }
  229.    }
  230.    function evade()
  231.    {
  232.       if(this.matrixVar == 2)
  233.       {
  234.          this.matrixVar = 0;
  235.          this.clip.flame.gotoAndPlay("flyStart");
  236.          this.clip.body.gotoAndPlay("flyStart");
  237.          this.f2 = "wander";
  238.       }
  239.       else if(this.f2 == "charging")
  240.       {
  241.          this.newChargeDir();
  242.       }
  243.       else if(this.f2 == "laserScoping" || this.laser.firing)
  244.       {
  245.          this.stopLaserFire();
  246.       }
  247.    }
  248.    function wait()
  249.    {
  250.       if(random(1000) >= 998 && _root.matrixComplete)
  251.       {
  252.          this.dir = this.findDir();
  253.          if(this.dir == _root.advanceDir)
  254.          {
  255.             this.matrixVar = 0;
  256.             this.xMovT = _root.advanceDir != "L" ? this.speed : -1 * this.speed;
  257.             if(random(2) > 0)
  258.             {
  259.                this.clip.flame.gotoAndPlay("flyStart");
  260.                this.clip.body.gotoAndPlay("flyStart");
  261.                this.f2 = "wander";
  262.             }
  263.             else
  264.             {
  265.                this.charge();
  266.             }
  267.          }
  268.          else if(this.dir == "U" || this.dir == "D")
  269.          {
  270.             this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  271.             this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  272.             this.matrixVar = 0;
  273.             this.c = 0;
  274.             this.f2 = "leavingMatrix";
  275.          }
  276.          else
  277.          {
  278.             this.dir = _root.advanceDir;
  279.          }
  280.       }
  281.    }
  282.    function leavingMatrix()
  283.    {
  284.       this.c = this.c + 1;
  285.       if(this.c > this.advanceMax2)
  286.       {
  287.          this.c = 0;
  288.          this.dir = this.findDir();
  289.          if(this.dir == _root.advanceDir)
  290.          {
  291.             this.yMovT = 0;
  292.             this.xMovT = _root.advanceDir != "L" ? this.speed : -1 * this.speed;
  293.             if(random(2) > 0)
  294.             {
  295.                this.f2 = "wander";
  296.             }
  297.             else
  298.             {
  299.                this.charge();
  300.             }
  301.          }
  302.       }
  303.    }
  304.    function findDir()
  305.    {
  306.       _root.d = _root.d + 1;
  307.       _root.attachMovie("feeler","feelerClip",_root.d);
  308.       var _loc7_ = [];
  309.       var _loc9_ = 0;
  310.       var _loc11_ = this.dirArray.length;
  311.       while(_loc9_ < _loc11_)
  312.       {
  313.          _root.feelerClip._x = this.x + this.feelerInfo[_loc9_][0];
  314.          _root.feelerClip._y = this.y + this.feelerInfo[_loc9_][1];
  315.          _root.feelerClip._width = this.feelerInfo[_loc9_][2];
  316.          _root.feelerClip._height = this.feelerInfo[_loc9_][3];
  317.          var _loc3_ = 0;
  318.          var _loc8_ = _root.chars.length;
  319.          var _loc6_ = false;
  320.          while(_loc3_ < _loc8_)
  321.          {
  322.             var _loc5_ = _root.chars[_loc3_] + "Clip";
  323.             if(_root.feelerClip.hitTest(_root[_loc5_]))
  324.             {
  325.                var _loc4_ = _root.chars[_loc3_];
  326.                if(_root[_loc4_].matrixVar == 2 && _loc4_ != this.Name + this.id)
  327.                {
  328.                   _loc6_ = true;
  329.                   break;
  330.                }
  331.             }
  332.             _loc3_ = _loc3_ + 1;
  333.          }
  334.          if(!_loc6_)
  335.          {
  336.             var _loc10_ = _root.advanceDir != "L" ? "L" : "R";
  337.             if(this.dirArray[_loc9_] != _loc10_)
  338.             {
  339.                _loc7_.push(this.dirArray[_loc9_]);
  340.             }
  341.          }
  342.          _loc9_ = _loc9_ + 1;
  343.       }
  344.       _loc9_ = 0;
  345.       _loc11_ = _loc7_.length;
  346.       if(_loc9_ < _loc11_)
  347.       {
  348.          if(_loc7_[_loc9_] == _root.advanceDir)
  349.          {
  350.             return _root.advanceDir;
  351.          }
  352.          return _loc7_[random(_loc7_.length)];
  353.       }
  354.    }
  355.    function death()
  356.    {
  357.       _root.stats.destroyed = _root.stats.destroyed + 1;
  358.       _root.stats.score += 50000;
  359.       _root.powerUp(this.x,this.y,50);
  360.       if(this.matrixVar == 1)
  361.       {
  362.          _root.matrixNum = _root.matrixNum + 1;
  363.          if(_root.matrixNum >= _root.matrixSize)
  364.          {
  365.             _root.matrixComplete = true;
  366.          }
  367.       }
  368.       var _loc3_ = 0;
  369.       var _loc4_ = _root["form" + this.form[0]].length;
  370.       while(_loc3_ < _loc4_)
  371.       {
  372.          if(_root["form" + this.form[0]][_loc3_] == "spaceManA" + this.id)
  373.          {
  374.             _root["form" + this.form[0]].splice(_loc3_,1);
  375.             if(_root["form" + this.form[0]].length == 0)
  376.             {
  377.                delete _root["form" + this.form[0]];
  378.                if(_root["formB" + this.form[0]] == "matrixed")
  379.                {
  380.                   _loc3_ = 0;
  381.                   _loc4_ = random(2) + 1;
  382.                   while(_loc3_ < _loc4_)
  383.                   {
  384.                      _root.createPowerUp([this.x,this.y,"coin25"]);
  385.                      _loc3_ = _loc3_ + 1;
  386.                   }
  387.                   _loc3_ = 0;
  388.                   _loc4_ = random(2) + 1;
  389.                   while(_loc3_ < _loc4_)
  390.                   {
  391.                      _root.createPowerUp([this.x,this.y,"coin10"]);
  392.                      _loc3_ = _loc3_ + 1;
  393.                   }
  394.                   _loc3_ = 0;
  395.                   _loc4_ = random(2) + 2;
  396.                   while(_loc3_ < _loc4_)
  397.                   {
  398.                      _root.createPowerUp([this.x,this.y,"coin5"]);
  399.                      _loc3_ = _loc3_ + 1;
  400.                   }
  401.                   _root.stats.score += 50000;
  402.                }
  403.                else
  404.                {
  405.                   _loc3_ = 0;
  406.                   _loc4_ = random(2) + 2;
  407.                   while(_loc3_ < _loc4_)
  408.                   {
  409.                      _root.createPowerUp([this.x,this.y,"coin25"]);
  410.                      _loc3_ = _loc3_ + 1;
  411.                   }
  412.                   _loc3_ = 0;
  413.                   _loc4_ = random(3) + 2;
  414.                   while(_loc3_ < _loc4_)
  415.                   {
  416.                      _root.createPowerUp([this.x,this.y,"coin10"]);
  417.                      _loc3_ = _loc3_ + 1;
  418.                   }
  419.                   _root.stats.score += 100000;
  420.                }
  421.                delete _root["formB" + this.form[0]];
  422.             }
  423.             break;
  424.          }
  425.          _loc3_ = _loc3_ + 1;
  426.       }
  427.       _root.createExploA([this.x + this.clip._width / 2 + _root.randRange(-20,20),this.y + this.clip._height / 2 + _root.randRange(-20,20),_root.randRange(80,130),_root.randRange(75,100),"Red"]);
  428.       _root.createExploA([this.x + this.clip._width / 2 + _root.randRange(-20,20),this.y + this.clip._height / 2 + _root.randRange(-20,20),_root.randRange(80,130),_root.randRange(75,100),"Green"]);
  429.       _root.createExploA([this.x + this.clip._width / 2 + _root.randRange(-20,20),this.y + this.clip._height / 2 + _root.randRange(-20,20),_root.randRange(80,130),_root.randRange(75,100),"Blue"]);
  430.       _root.audio.playLevel4("spaceManX" + (random(3) + 1),_root.randRange(15,25));
  431.       var _loc5_ = 0;
  432.       var _loc6_ = random(4) + 3;
  433.       while(_loc5_ < _loc6_)
  434.       {
  435.          _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"spaceManA","Yellow"]);
  436.          _loc5_ = _loc5_ + 1;
  437.       }
  438.       _root.createEnemySoul([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"yellow"]);
  439.       _root.removeChar("spaceManA" + this.id);
  440.    }
  441.    function advance()
  442.    {
  443.       this.dir = _root.advanceDir;
  444.       this.xMovT = _root.advanceDir != "L" ? 1 * (this.speed / 2) : -1 * (this.speed / 2);
  445.       this.clip.flame.gotoAndPlay("advance");
  446.       this.f2 = "advancing";
  447.    }
  448.    function advancing()
  449.    {
  450.       this.c = this.c + 1;
  451.       if(this.c > this.advanceMax)
  452.       {
  453.          this.xMovT = 0;
  454.          this.c = 0;
  455.          this.f2 = "wait";
  456.          _root.d = _root.d + 1;
  457.          _root.attachMovie("sight","sightClip",_root.d);
  458.          _root.sightClip.gotoAndStop("hindSight");
  459.          _root.sightClip._x = this.x;
  460.          _root.sightClip._y = this.y;
  461.          if(_root.advanceDir == "L")
  462.          {
  463.             _root.sightClip._rotation = 180;
  464.          }
  465.          if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
  466.          {
  467.             _root.broBehind();
  468.          }
  469.          removeMovieClip(_root.sightClip);
  470.       }
  471.    }
  472.    function newDir()
  473.    {
  474.       if(random(10) > 1)
  475.       {
  476.          this[this.axis + "MovT"] = 0;
  477.          this.dir = _root.getDir(this.x,this.y);
  478.          this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  479.          this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  480.       }
  481.       else
  482.       {
  483.          this[this.axis + "MovT"] = 0;
  484.          this.axis = random(10) <= 4 ? "y" : "x";
  485.          this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
  486.          this.getDirString();
  487.       }
  488.    }
  489.    function newChargeDir()
  490.    {
  491.       if(random(10) > 1)
  492.       {
  493.          this.dir = _root.getDir(this.x,this.y);
  494.       }
  495.       else
  496.       {
  497.          this.dir = this.dirArray[random(4)];
  498.       }
  499.    }
  500.    function wander()
  501.    {
  502.       if(random(100) > 95 + _root.dif.wander)
  503.       {
  504.          this.newDir();
  505.       }
  506.       else if(random(100) > 97)
  507.       {
  508.          if(this.dir == "U" || this.dir == "D")
  509.          {
  510.             this.laserScope();
  511.          }
  512.          else if(random(10) > 7)
  513.          {
  514.             this.charge();
  515.          }
  516.       }
  517.    }
  518.    function charge()
  519.    {
  520.       this.clip.body.gotoAndPlay("chargeStart");
  521.       this.clip.flame.gotoAndPlay("charge");
  522.       this.speed = this.speedOrig;
  523.       this.speed *= 1.5;
  524.       this.axis = "x";
  525.       this.yMovT = 0;
  526.       this[this.axis + "MovT"] = this.dir != "L" ? this.speed : -1 * this.speed;
  527.       this.f2 = "charging";
  528.       this.c = 0;
  529.       this.cMax = _root.randRange(30,120);
  530.       _root.audio.playLevel3("spaceManCharge",_root.randRange(25,35));
  531.    }
  532.    function charging()
  533.    {
  534.       if(random(100) > 95)
  535.       {
  536.          this.newChargeDir();
  537.       }
  538.       this.c = this.c + 1;
  539.       if(this.c == this.cMax)
  540.       {
  541.          this.clip.body.gotoAndPlay("chargeEnd");
  542.          this.clip.flame.gotoAndPlay("fly");
  543.          this.speed = this.speedOrig;
  544.          this[this.axis + "MovT"] = this.dir != "L" ? this.speed : -1 * this.speed;
  545.          this.f2 = "wander";
  546.       }
  547.    }
  548.    function laserScope()
  549.    {
  550.       this.laser.c = 0;
  551.       this.laser.c2 = 0;
  552.       this.laser.c2Max = _root.randRange(2,4);
  553.       this.f2 = "laserScoping";
  554.       this.speed /= 3;
  555.       this[this.axis + "MovT"] /= 3;
  556.       this.clip.body.head.gotoAndPlay("scope");
  557.       this.clip.body.gotoAndStop("hover");
  558.       _root.audio.playLevel2("spaceManWarning" + (random(3) + 1),_root.randRange(43,50));
  559.    }
  560.    function laserScoping()
  561.    {
  562.       this.laser.c = this.laser.c + 1;
  563.       if(this.laser.c == 20)
  564.       {
  565.          this.laser.c2 = this.laser.c2 + 1;
  566.          _root.d = _root.d + 1;
  567.          _root.attachMovie("sight","sightClip",_root.d);
  568.          _root.sightClip.gotoAndStop("bomberBLaser");
  569.          _root.sightClip._x = this.x;
  570.          _root.sightClip._y = this.y;
  571.          if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
  572.          {
  573.             this.laser.dir = "L";
  574.             this.fireLaser(false);
  575.          }
  576.          else
  577.          {
  578.             _root.sightClip._rotation = 180;
  579.             if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
  580.             {
  581.                this.laser.dir = "R";
  582.                this.fireLaser(false);
  583.             }
  584.          }
  585.          removeMovieClip(_root.sightClip);
  586.          this.laser.c = 0;
  587.       }
  588.       else if(this.laser.c2 >= this.laser.c2Max)
  589.       {
  590.          this.speed = this.speedOrig;
  591.          this[this.axis + "MovT"] *= 3;
  592.          this.f2 = "wander";
  593.          this.clip.body.head.gotoAndPlay("front");
  594.       }
  595.    }
  596.    function fireLaser(pmatrixed)
  597.    {
  598.       this.clip.gotoAndStop(this.laser.dir);
  599.       this.clip.body.head.gotoAndStop("front");
  600.       this.laser.matrixed = pmatrixed;
  601.       this.f2 = "";
  602.       this.clip.body.head.eyes.gotoAndPlay("glowStart");
  603.       this.clip.body.hover.gotoAndPlay("topStart");
  604.       this.laser.l = _root.randRange(5,25);
  605.       this.laser.firing = true;
  606.       this.laser.top = true;
  607.       this.laser.c = 0;
  608.    }
  609.    function stopLaserFire()
  610.    {
  611.       this.laser.firing = false;
  612.       this.clip.body.head.eyes.gotoAndPlay("glowEnd");
  613.       if(this.laser.top)
  614.       {
  615.          this.clip.body.hover.gotoAndPlay("topEnd");
  616.       }
  617.       else
  618.       {
  619.          this.clip.body.hover.gotoAndPlay("botEnd");
  620.       }
  621.       if(!this.laser.matrixed)
  622.       {
  623.          this.speed = this.speedOrig;
  624.          this[this.axis + "MovT"] *= 3;
  625.          this.f2 = "wander";
  626.       }
  627.    }
  628.    function death2()
  629.    {
  630.       _root.removeChar("spaceManA" + this.id);
  631.    }
  632.    function main()
  633.    {
  634.       this[this.f2]();
  635.       if(this.oldDir != this.dir)
  636.       {
  637.          if(this.f2 != "charging" && this.oldDir != "matrix")
  638.          {
  639.             this.clip.gotoAndStop(this.dir);
  640.             if(this.dir == "U")
  641.             {
  642.                this.clip.body.gotoAndPlay("flyEnd");
  643.                this.clip.flame.gotoAndPlay("up2");
  644.             }
  645.             else if(this.dir == "D")
  646.             {
  647.                this.clip.body.gotoAndPlay("flyEnd");
  648.                this.clip.flame.gotoAndStop("wait");
  649.             }
  650.             else if(this.f2 != "wait")
  651.             {
  652.                this.clip.body.gotoAndPlay("flyStart");
  653.                this.clip.flame.gotoAndPlay("fly");
  654.             }
  655.          }
  656.          else if(this.oldDir != "matrix")
  657.          {
  658.             this.clip.gotoAndStop(this.dir);
  659.             if(this.oldDir == "L" || this.oldDir == "R")
  660.             {
  661.                if(this.dir == "U")
  662.                {
  663.                   this.axis = "y";
  664.                   this.yMovT = -1 * this.speed;
  665.                   this.clip.body.gotoAndPlay("upStart");
  666.                   this.clip.flame.gotoAndPlay("upStart");
  667.                }
  668.                else if(this.dir == "D")
  669.                {
  670.                   this.axis = "y";
  671.                   this.yMovT = this.speed;
  672.                   this.clip.body.gotoAndPlay("downStart");
  673.                   this.clip.flame.gotoAndPlay("downStart");
  674.                }
  675.                else
  676.                {
  677.                   this.axis = "x";
  678.                   this.yMovT = 0;
  679.                   this.xMovT = this.dir != "L" ? this.speed : -1 * this.speed;
  680.                   this.clip.body.gotoAndPlay("chargeStart");
  681.                   this.clip.flame.gotoAndPlay("charge");
  682.                }
  683.             }
  684.             else if(this.dir == "U")
  685.             {
  686.                this.axis = "y";
  687.                this.xMovT = 0;
  688.                this.clip.body.gotoAndPlay("hover");
  689.                this.clip.flame.gotoAndPlay("up2");
  690.             }
  691.             else if(this.dir == "D")
  692.             {
  693.                this.axis = "y";
  694.                this.xMovT = 0;
  695.                this.clip.body.gotoAndPlay("downStart");
  696.                this.clip.flame.gotoAndPlay("downStart");
  697.             }
  698.             else
  699.             {
  700.                this.axis = "x";
  701.                this.xMovT = this.dir != "L" ? this.speed : -1 * this.speed;
  702.                if(this.oldDir == "U")
  703.                {
  704.                   this.clip.body.gotoAndPlay("upStart");
  705.                   this.clip.flame.gotoAndPlay("upStart");
  706.                }
  707.                else
  708.                {
  709.                   this.clip.body.gotoAndPlay("downStart");
  710.                   this.clip.flame.gotoAndPlay("downStart");
  711.                }
  712.             }
  713.          }
  714.       }
  715.       this.oldDir = this.dir;
  716.       if(this.laser.firing)
  717.       {
  718.          this.laser.c = this.laser.c + 1;
  719.          if(this.laser.c / 4 == Math.round(this.laser.c / 4))
  720.          {
  721.             if(this.laser.top)
  722.             {
  723.                this.laser.top = false;
  724.                this.clip.body.hover.gotoAndPlay("topToBot");
  725.                var _loc9_ = this.laser.dir != "L" ? -9 : -8;
  726.                _root.enemyShotID = _root.enemyShotID + 1;
  727.                _root["spaceManALaser" + _root.enemyShotID] = new classes.shots.SpaceManALaser(this.x + _loc9_,this.y + 6,this.laser.c,this.laser.dir,_root.enemyShotID);
  728.                _root.addEnemyShot("spaceManALaser" + _root.enemyShotID);
  729.             }
  730.             else
  731.             {
  732.                this.laser.top = true;
  733.                this.clip.body.hover.gotoAndPlay("botToTop");
  734.                _loc9_ = this.laser.dir != "L" ? 9 : -8;
  735.                _root.enemyShotID = _root.enemyShotID + 1;
  736.                _root["spaceManALaser" + _root.enemyShotID] = new classes.shots.SpaceManALaser(this.x + _loc9_,this.y + 9,this.laser.c,this.laser.dir,_root.enemyShotID);
  737.                _root.addEnemyShot("spaceManALaser" + _root.enemyShotID);
  738.             }
  739.             _root.audio.playLevel3("spaceManFire" + (random(5) + 1),_root.randRange(15,25));
  740.          }
  741.          if(this.laser.c > this.laser.l)
  742.          {
  743.             this.stopLaserFire();
  744.          }
  745.       }
  746.       if(this.nudging)
  747.       {
  748.          this.xA *= 0.5;
  749.          this.yA *= 0.5;
  750.          this.nc = this.nc + 1;
  751.          var _loc10_ = 255 - this.nc * 17;
  752.          this.colorTrans.redOffset = _loc10_;
  753.          this.colorTrans.greenMultiplier = this.nc / 15;
  754.          this.colorTrans.blueMultiplier = this.nc / 15;
  755.          this.trans.colorTransform = this.colorTrans;
  756.          if(this.nc == 15)
  757.          {
  758.             this.xA = this.yA = 0;
  759.             this.nudging = false;
  760.             this.colorTrans.redOffset = this.colorR;
  761.             this.colorTrans.greenMultiplier = 1;
  762.             this.colorTrans.blueMultiplier = 1;
  763.             this.trans.colorTransform = this.colorTrans;
  764.          }
  765.       }
  766.       var _loc4_ = 0;
  767.       var _loc7_ = _root.broShots.length;
  768.       while(_loc4_ < _loc7_)
  769.       {
  770.          var _loc6_ = _root.broShots[_loc4_] + "Clip";
  771.          if(this.clip.hitTest(_root[_loc6_]))
  772.          {
  773.             var _loc3_ = _root.broShots[_loc4_];
  774.             var _loc5_ = this.life;
  775.             this.life -= _root[_loc3_].power;
  776.             _root.power = _root[_loc3_].power;
  777.             _root.life = this.life;
  778.             if(this.life < 1 || this.life == NaN)
  779.             {
  780.                this.f2 = "death";
  781.             }
  782.             else
  783.             {
  784.                this.nudge(_root[_loc3_].xMov,_root[_loc3_].yMov,5);
  785.                if(random(3) == 0)
  786.                {
  787.                   _root.audio.playLevel4("spaceManHit" + (random(3) + 1),_root.randRange(23,32));
  788.                }
  789.                else
  790.                {
  791.                   _root.audio.playLevel2("spaceManHit" + (random(2) + 4),_root.randRange(15,20));
  792.                }
  793.                if(this.f2 == "wait" || this.f2 == "advancing")
  794.                {
  795.                   this.matrixVar = 0;
  796.                   this.charge();
  797.                }
  798.                else if(this.f2 == "wander" || this.f2 == "laserScoping")
  799.                {
  800.                   if(random(2) == 0)
  801.                   {
  802.                      this.speed = this.speedOrig;
  803.                      this[this.axis + "MovT"] = 0;
  804.                      this.axis = this.axis != "x" ? "x" : "y";
  805.                      this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
  806.                      this.getDirString();
  807.                   }
  808.                   else if(random(2) == 0)
  809.                   {
  810.                      this.axis = "x";
  811.                      this.dir = random(2) != 0 ? "R" : "L";
  812.                      this.charge();
  813.                   }
  814.                }
  815.                else if(this.f2 == "charging")
  816.                {
  817.                   this.newChargeDir();
  818.                }
  819.             }
  820.             _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
  821.             _root[_loc3_].exploX = this.x + this.clip._width / 2;
  822.             _root[_loc3_].exploY = this.y + this.clip._height / 2;
  823.             _root[_loc3_].hit(_loc5_);
  824.             break;
  825.          }
  826.          _loc4_ = _loc4_ + 1;
  827.       }
  828.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  829.       {
  830.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  831.          this.bombed(20);
  832.       }
  833.       if(!this.moveScripted)
  834.       {
  835.          var _loc8_ = false;
  836.          if(this.x > 950)
  837.          {
  838.             _loc8_ = true;
  839.             this.dir = "L";
  840.          }
  841.          else if(this.x < 50)
  842.          {
  843.             _loc8_ = true;
  844.             this.dir = "R";
  845.          }
  846.          else if(this.y < 50)
  847.          {
  848.             _loc8_ = true;
  849.             this.dir = "D";
  850.          }
  851.          else if(this.y > 550)
  852.          {
  853.             _loc8_ = true;
  854.             this.dir = "U";
  855.          }
  856.          if(_loc8_)
  857.          {
  858.             this.xMovT = 0;
  859.             this.yMovT = 0;
  860.             this.speed = this.speedOrig;
  861.             this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  862.             this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  863.             this.f2 = "wander";
  864.          }
  865.       }
  866.       if(this.x > 1100 || this.x < -100 || this.y < -100 || this.y > 700)
  867.       {
  868.          delete _root["form" + this.form[0]];
  869.          delete _root["formB" + this.form[0]];
  870.          this.f2 = "death2";
  871.       }
  872.       if(this.xMovT < this.xMov)
  873.       {
  874.          this.xMov -= 1;
  875.       }
  876.       else if(this.xMovT > this.xMov)
  877.       {
  878.          this.xMov += 1;
  879.       }
  880.       else
  881.       {
  882.          this.xMov = this.xMovT;
  883.       }
  884.       if(this.yMovT < this.yMov)
  885.       {
  886.          this.yMov -= 1;
  887.       }
  888.       else if(this.yMovT > this.yMov)
  889.       {
  890.          this.yMov += 1;
  891.       }
  892.       else
  893.       {
  894.          this.yMov = this.yMovT;
  895.       }
  896.       this.x += this.xMov + this.xA;
  897.       this.y += this.yMov + this.yA + 0.5 * Math.sin(this.hc += 0.075);
  898.       this.clip._x = this.x;
  899.       this.clip._y = this.y;
  900.    }
  901. }
  902.